package Class_04_07;

import java.awt.*;

abstract class Shape
{
    private double area;
    private double per;
    private String color;

    public Shape(String color) {
        this.color = color;
    }

    public Shape() {
    }


    abstract void getArea();
    abstract void getPer();

    public String getColor() {
        return color;
    }

    public abstract void showAll();
}

class Rectangle extends Shape
{
    private double Width;
    private double height;

    public Rectangle(String color, double width, double height) {
        super(color);
        this.Width = width;
        this.height = height;
    }

    public Rectangle() {
    }


    public void getArea()
    {
        double area = Width * height;
        System.out.println("该图形面积为：" + area);
    }

    public void getPer()
    {
        double per = 2 * (Width + height);
        System.out.println("该图形周长为：" + per);
    }


    public void showAll()
    {
        getArea();
        getPer();
        System.out.println("该图形颜色为：" + getColor());
    }
}

class Circle extends Shape
{
    private double radius;

    public Circle() {
    }

    public Circle(String color, double radius) {
        super(color);
        this.radius = radius;
    }

    public Circle(double radius) {
        this.radius = radius;
    }

    public void getArea()
    {
        double area = Math.PI * radius * radius;
        System.out.println("该图形面积为：" + area);
    }

    public void getPer()
    {
        double per = Math.PI * 2 *radius;
        System.out.println("该图形周长为：" + per);
    }

    public void showAll()
    {
        getArea();
        getPer();
        System.out.println("该图形颜色为：" + getColor());
    }
}

public class Main1 {
    public static void main(String[] args) {
        Rectangle r1 = new Rectangle("red",30,20);
        r1.showAll();

        System.out.println("=============================");

        Circle r2 = new Circle("yellow",3);
        r2.showAll();
    }
}
